﻿using Microsoft.AspNetCore.Http;
using NPOI.SS.Formula.Functions;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Text;
using System.Threading.Tasks;
using XW.Utils;

namespace XW.Core
{
	public static class IInsertableExtent
    {
		public static IInsertable<T> setColumnsInsertUserAndTime<T>(this IInsertable<T>  u) where T : EntityBase, new()
		{
			u.InsertColumns(item => item.CreateTime == SqlFunc.GetDate());
			string? userId = SXHttpContext.Current.User.FindFirstValue(JwtTokenConst.JWT_USER_ID);// 用户id
			long id = CommonHelper.ToInt64(userId,0);
			u.InsertColumns(item => item.CreateUserId == id);
			return u;
		}
	}
}
